# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=py3-m2crypto
_pyname=M2Crypto
pkgver=0.41.0
pkgrel=2
pkgdesc="A crypto and SSL toolkit for Python3"
url="https://pypi.org/project/M2Crypto/"
arch="all"
license="MIT"
depends="python3"
makedepends="python3-dev py3-setuptools openssl-dev swig py3-gpep517"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/${_pyname:0:1}/$_pyname/$_pyname-$pkgver.tar.gz"
builddir="$srcdir/$_pyname-$pkgver"
options="!check" # test_public_encrypt and test_server_simple_timeouts fail

replaces="py-m2crypto" # Backwards compatibility
provides="py-m2crypto=$pkgver-r$pkgrel" # Backwards compatibility

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	gpep517 install-wheel --destdir .testenv --prefix '' .dist/*.whl
	.testenv/bin/python3 -m unittest discover
}

package() {
	gpep517 install-wheel --destdir "$pkgdir" \
		.dist/*.whl
}

sha512sums="
50ca5e32ae999b9ecdc7f3bbd35221b4a7523ef29e54eb4bc266457723117718955f99b9e7ac42a4cb982f0e22a94e5c852d6886d7dfb157d040ad86c17660fb  M2Crypto-0.41.0.tar.gz
"
